package com.aizu.service;

import java.sql.SQLException;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Service;

import com.isp.jdbc.service.JdbcService;
import com.isp.utils.JdbcUtils;

@Service
public class CommonService extends JdbcService {

	/**
	 * 地市区县
	 * 
	 * @return
	 * @throws SQLException 
	 */
	public List<Map<String, Object>> findAllArea() throws SQLException {
		return find("select * from t_area", null);
	}

	/**
	 * 街道
	 * 
	 * @return
	 * @throws SQLException 
	 */
	public List<Map<String, Object>> findStreet() throws SQLException {
		return find("select * from t_street", null);
	}

	/**
	 * 社区
	 * 
	 * @return
	 * @throws SQLException 
	 */
	public List<Map<String, Object>> findDepartment() throws SQLException {
		return find("select * from t_department", null);
	}

	/**
	 * 屋（小区）
	 * 
	 * @return
	 * @throws SQLException 
	 */
	public List<Map<String, Object>> findCommunity() throws SQLException {
		return find("select * from t_community", null);
	}

	/**
	 * 查找订单
	 * 
	 * @param condition
	 * @return
	 * @throws Exception
	 */
	public Map<String, Object> findOrder(Map<String, Object> condition)
			throws Exception {
		Map<String, Object> querySqlParam = JdbcUtils.createSqlParam(
				JdbcUtils.SQLTYPE_QUERY, "t_order", null, condition);
		return this.findOnly((String) querySqlParam.get(JdbcUtils.SQL),
				(Object[]) querySqlParam.get(JdbcUtils.PARAM));
	}
}
